package com.study.system.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.edu.common.entity.CourseOrientation;
import com.study.system.course.mapper.CourseOrientationMapper;
import com.study.system.course.service.CourseOrientationService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseOrientationServiceImpl extends ServiceImpl<CourseOrientationMapper, CourseOrientation>
implements CourseOrientationService{

    @Resource
    private CourseOrientationMapper mapper;

    @Override
    public List<CourseOrientation> getAllCourseOrientations() {
        //查询parentId为0的方向
        List<CourseOrientation> courseOrientations = mapper.selectList(
                new QueryWrapper<CourseOrientation>().lambda().eq(CourseOrientation::getParentId, 0));
        return courseOrientations;
    }

    @Override
    public List<CourseOrientation> getCourseOrientationsByParentId(Integer parentId) {
        //按parentId查询下级方向
        List<CourseOrientation> courseOrientations = mapper.selectList(
                new QueryWrapper<CourseOrientation>().lambda().eq(CourseOrientation::getParentId, parentId));
        return courseOrientations;
    }
}
